<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>所有任务</title>
<script type="text/javascript">
	var $grid, $nodeGrid;
	var selectTableRow;//选中的行数据
	$(function() {
		$grid = $("#grid")
				.datagrid(
						{
							method : "get",
							url : "${ctx}/bpm/console/console-listTasks",
							idField : 'id',
							remoteSort : true,
							multiSort : true,
							rownumbers : true,
							fit : true,
							toolbar : '#tt',
							singleSelect : true,
							pagination : true,
							pageList : [ 10, 20, 30, 40, 50, 100 ],
							columns : [ [
									{
										field : 'ck',
										checkbox : true
									},
									{
										field : 'id',
										title : '编号',
										sortable : true
									},
									{
										field : 'name',
										title : '任务名称',
										sortable : true
									},
									{
										field : 'processDefinitionId',
										title : '流程定义ID',
										sortable : true
									},
									{
										field : 'startTime',
										title : '创建时间',
										sortable : true
									},
									{
										field : 'assigneeName',
										title : '负责人',
										sortable : true
									},
									{
										field : 'processInstanceId',
										title : '历史',
										formatter : function(val, row) {
											var result = "<a class='l-btn l-btn-plain' href='#'  onclick='viewHistory(\""
													+ row.processInstanceId
													+ "\")'><span class='l-btn-left'><span class='l-btn-text icon-hamburg-graphic l-btn-icon-left'>历史</span></span></a>";
											result += "<a class='l-btn l-btn-plain' href='#'  onclick='jump(\""
													+ row.executionId
													+ "\")'><span class='l-btn-left'><span class='l-btn-text icon-hamburg-shipping l-btn-icon-left'>自由跳转</span></span></a>";
											return result;
										}
									} ] ],
							enableHeaderClickMenu : true, //此属性开启表头列名称右侧那个箭头形状的鼠标左键点击菜单
							enableHeaderContextMenu : true, //此属性开启表头列名称右键点击菜单
							enableRowContextMenu : false
						});
		$("#search").click(function() {
			$grid.datagrid('load', getSearchConditions("#tt"));
		});
	});
	function viewHistory(processInstanceId) {
		window.parent.addTab("processHistory","流程历史", "${ctx}/bpm/confForm/task-viewHistory?processInstanceId=" + processInstanceId);
	}
	function jump(executionId) {
		$('#activityId').combobox({
			url : '${ctx}/bpm/console/activityCombobox?executionId=' + executionId,
			method : 'get',
			editable : false,
			idField : 'value',
			textField : 'text',
			dataPlain : true
		});
		$("#fm").form("clear");
		$("#fm").form("load", {
			"executionId" : executionId
		});
		$("#dlg").dialog("open").dialog("setTitle", "选择节点");
	}
	function fn_save() {
		$("#fm").form("submit", {
			url : "${ctx}/bpm/console/jump",
			success : function(data) {
				$grid.datagrid("load");
				$.messager.show({
					msg : data.msg,
					icon : "info",
					position : "bottomRight"
				});
				$("#dlg").dialog('close');
			},
			onSubmit:function(){
				alert(1)
			}
		});
	}
</script>
</head>
<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
		<div id="tt" class="row">
		<div class="col-md-12">
		<form class="form-grid-search form-inline">
				<div class="form-group">
					<input type="text" class="form-control" name="search_LIKE_processDefinitionId" placeholder="流程定义ID" />
				</div>
				<button type="button" id="search" class="btn btn-primary">
					<span class="glyphicon glyphicon-search"></span> 查询
				</button>
			</form>
		</div>
		</div>
	</div>
	<div id="dlg" class="easyui-dialog" style="width: 360px; height: 220px; padding: 10px 20px"
		data-options="iconCls:'icon-save',resizable:true,modal:true,inline:false, buttons:[
                    { text: '保存', iconCls: 'icon-ok', handler: function () { fn_save(); } },
                    { text: '取消', iconCls:'icon-cancel', handler: function () { $('#dlg').dialog('close'); } }
                ],closed:true">
		<form id="fm" method="post">
			<input type="hidden" name="executionId" />
			<fieldset style="border: solid 1px #aaa; padding: 3px;">
				<legend>流程节点</legend>
				<table id="tbl">
					<tr>
						<td>节点名称:</td>
						<td><input id="activityId" name="activityId" class="easyui-validatebox" data-options="required:true"></td>
					</tr>
				</table>
			</fieldset>
		</form>
	</div>
</body>
</html>
